﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using OF.Lib.DataAccess.Entity;
using OF.Lib.Utility;

namespace OF.Lib.DataAccess.Core
{
    public class SqlBuilderMysqlImpl : SqlBuilderBase, ISqlBuilder
    {
        public string BuildPagedQuerySql(SQL sqlCfg, QueryFilter filter)
        {
            throw new NotImplementedException();
        }


 
        public string BuildSO_InsertSql<T>(string dbName, object dataParameter, string excludeProperties = null) where T : class, new()
        {
            throw new NotImplementedException();
        }

        public string BuildSO_InsertSqlWithReturnPK<T>(string dbName, object dataParameter, string excludeProperties = null) where T : class, new()
        {
            throw new NotImplementedException();
        }

         




        public string BuildSO_Load(string dbName, string table, string strWhere)
        {
            return string.Format("SELECT  * FROM {0}.{1} WITH(NOLOCK) WHERE {2} limit 1", dbName, table, strWhere);
        }
        public string BuildSO_GetList(int? top, string dbName, string table, string strWhere, string orderBy)
        {
            string sqlTemplate = string.Empty;
            if (top.HasValue && top.Value > 0)
            {
                sqlTemplate = "SELECT TOP(" + top.ToString() + ") * FROM {0}.{1} WITH(NOLOCK) WHERE {2} {3} limit " + top.ToString();
            }
            else
            {
                sqlTemplate = "SELECT * FROM {0}.{1} WITH(NOLOCK) WHERE {2} {3}";
            }
            if (!string.IsNullOrWhiteSpace(orderBy))
            {
                orderBy = " ORDER BY " + orderBy;
            }

            return string.Format(sqlTemplate, dbName, table, strWhere, orderBy);
        }

        public string BuildSO_Update(string dbName, string table, object dataParameter, string excludeProperties, string strWhere, ref dynamic paramObject)
        {
            throw new NotImplementedException();
        }

        public string BuildSO_Delete(string dbName, string table, string strWhere)
        {
            throw new NotImplementedException();
        }
    }
}
